package com.authority.basic.general_basic.test_thread;

import java.util.concurrent.CountDownLatch;

public class  myThread extends Thread{
    private Runnable run;
    private CountDownLatch start;
    private CountDownLatch end;
    public myThread(Runnable run, CountDownLatch start, CountDownLatch end){
        this.run=run;
        this.start=start;
        this.end=end;
    }
    @Override
    public void run() {
        try {
            start.await();//线程等待一起执行
            run.run();
        } catch (InterruptedException e) {
            System.out.println("error...");
        } finally {
            end.countDown();
        }

    }
}
